package com.gxuwz.medical.tools;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {

	/**
	 * 在载入学生信息时日期类型在JSONUtil中发生错误，这里进行转换
	 * 
	 * @param o
	 * @param format
	 * @return
	 */
	public static String formatDate(Date date, String format) {
		String result = "";
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		if (date != null) {
			result = sdf.format(date);
		}
		return result;
	}

	public static Date formatString(String str, String format) throws Exception {
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		return sdf.parse(str);
	}
}